package jp.co.sharp.android.parents.kidsguard.activity.sendImage.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import jp.co.sharp.android.parents.kidsguard.R;

public class PreviewDlg extends Dialog {

    private OnSendOriginImageListener mOnSendOriginImageListener;
    private OnCutImageListener mOnCutImageListener;
    private PreviewDlg mPreviewDlg;

    public PreviewDlg(@NonNull Context context) {
        super(context);
        this.mPreviewDlg = this;
    }

    public PreviewDlg(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        this.mPreviewDlg = this;
    }

    protected PreviewDlg(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        this.mPreviewDlg = this;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dlg_preview);

        TextView sendOriginImage = (TextView)findViewById(R.id.sendOriginImage);
        sendOriginImage.setOnClickListener(new ListenerSendOriginImage());
        TextView cutImage = (TextView)findViewById(R.id.cutImage);
        cutImage.setOnClickListener(new ListenerCutImage());
    }

    /**
     * そのままのサイズで送る
     */
    public interface OnSendOriginImageListener {
        void onOperateSet();
    }

    /**
     * 壁紙サイズに加工して送る
     */
    public interface OnCutImageListener {
        void onOperateSet();
    }

    /*
     * 对外公开方法让Activity实现
     */
    public void setSendOriginImageListener(OnSendOriginImageListener callBack) {
        mOnSendOriginImageListener = callBack;
    }

    /*
     *  对外公开方法让Activity实现
     */
    public void setCutImageListener(OnCutImageListener callBack) {
        mOnCutImageListener = callBack;
    }

    class ListenerSendOriginImage implements View.OnClickListener {
        @Override
        public void onClick(View view) {
            if (mOnSendOriginImageListener != null) {
                mOnSendOriginImageListener.onOperateSet();
            }
        }
    }
    class ListenerCutImage implements View.OnClickListener {

        @Override
        public void onClick(View view) {
            if (mOnCutImageListener != null) {
                mOnCutImageListener.onOperateSet();
            }
        }
    }
}




























